package com.ybkj.o2o.zhuanche.common.query;

import org.apache.commons.lang.StringUtils;

/**
 * Created by YH on 16/10/20.
 */
public class CarQuery {
  
  private Long companyId;
  
  private Long carTypeId;
  
  private String carNumber;
  
  private String employName;
  
  private String employPhone;
  
  private Integer status; //0 空闲 ,1 忙碌 , 2 离线
  
  private String keyword; //like 查询

  private String appKey;

  private Integer page;

  private Integer rows;

  private Integer offset;
  
  private String flights;

  private Long[] ids;
  
  private Integer upStatus;

  public Integer getUpStatus() {
	return upStatus;
}

public void setUpStatus(Integer upStatus) {
	this.upStatus = upStatus;
}

public Long[] getIds() {
    return ids ==null || ids.length==0?null:ids;
  }

  public void setIds(Long[] ids) {
    this.ids = ids;
  }
  

  public String getFlights() {
	return flights;
}

public void setFlights(String flights) {
	this.flights = flights;
}

public String getEmployPhone() {
    return employPhone;
  }

  public void setEmployPhone(String employPhone) {
    this.employPhone = employPhone;
  }

  public Long getCompanyId() {
    return companyId;
  }

  public void setCompanyId(Long companyId) {
    this.companyId = companyId;
  }

  public Long getCarTypeId() {
    return carTypeId;
  }

  public void setCarTypeId(Long carTypeId) {
    this.carTypeId = carTypeId;
  }

  public String getCarNumber() {
    return carNumber;
  }
  /**
   * 模糊查询.
   */
  
  public void setCarNumber(String carNumber) {
    if (StringUtils.isNotBlank(carNumber)) {
      this.carNumber = "%" + carNumber + "%";
    } else {
      this.carNumber = null;
    }
  }

  public String getEmployName() {
    return employName;
  }
  /**
   * 模糊查询.
   */
  
  public void setEmployName(String employName) {
    if (StringUtils.isNotBlank(employName)) {
      this.employName = "%" + employName + "%";
    } else {
      this.employName = null;
    }
  }

  public Integer getStatus() {
    return status;
  }

  public void setStatus(Integer status) {
    this.status = status;
  }

  public String getKeyword() {
    return keyword;
  }

  /**
   * 普通字符串转换为数据库模糊查询的字符串，即两边连接'%'.
   */
  public void setKeyword(String keyword) {
    if (StringUtils.isNotBlank(keyword)) {
      this.keyword = "%" + keyword + "%";
    } else {
      this.keyword = null;
    }
  }

  public String getAppKey() {
    return appKey;
  }

  public void setAppKey(String appKey) {
    this.appKey = appKey;
  }

  public Integer getPage() {
    return page;
  }

  public void setPage(Integer page) {
    this.page = page;
  }

  public Integer getRows() {
    return rows;
  }

  public void setRows(Integer rows) {
    this.rows = rows;
  }

  /**
   * 根据page和rows计算出偏移量.
   */
  public Integer getOffset() {
    if (getPage() == null || getRows() == null) {
      return null;
    }
    if (getPage() > 1) {
      return (getPage() - 1) * getRows();
    }

    return offset;
  }

  public void setOffset(Integer offset) {
    this.offset = offset;
  }


}
